import { defineStore } from "pinia";
import { ref } from "vue";
import { userGetInfoService } from "@/api/user";
const user = ref({})
const getUser = async () => {
  const res = await userGetInfoService() // 请求获取数据
  user.value = res.data.data
}

export const useUserStore = defineStore("user", () => {
  const token = ref('');
  const setToken = (newToken) => {
    token.value = newToken;
  }
  const removeToken = () => {
    token.value = '';
  }

  const setUser = (newUser) => {
    user.value = newUser;
  }
  return {
    token,
    setToken,
    removeToken,
    getUser,
    user,
    setUser
  }
}, {
  persist: true
})
